<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
        var box = document.querySelector('.box')
        var flag = true
        box.onclick = function() {
            if (flag) {
                box.style.width = '300px'
                box.style.height = '300px'
                //JS里要采用驼峰命名法比如 background-color 要写成backgroundColor
                box.style.backgroundColor = 'purple'
                flag = false
            } else {
                box.style.width = '200px'
                box.style.height = '200px'
                box.style.backgroundColor = 'pink'
                flag = true
            }
        }
    </script>
</body>
</html>